//
//  MyOrderTableViewCell.m
//  CloudMD
//
//  Created by apple on 16/2/24.
//  Copyright (c) 2016年 HuaZhengInfo. All rights reserved.
//

#import "MyOrderTableViewCell.h"
#import "MyOrderListModel.h"

@implementation MyOrderTableViewCell

//- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
//    
//    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
//        
//        [self buildUI];
//    }
//    return self;
//}
//
//- (void)buildUI{
//    
//    _mainLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, self.frame.size.width - 150, self.frame.size.height * 0.6)];
//    if (iPhone4) {
//        _mainLabel.frame = CGRectMake(10, 0, self.frame.size.width - 150, self.frame.size.height * 0.6);
//    }
//    _mainLabel.text = @"";
//    _mainLabel.textAlignment = NSTextAlignmentLeft;
//    _mainLabel.textColor = [UIColor blackColor];
//    _mainLabel.font = [UIFont systemFontOfSize:18];
//    [self.contentView addSubview:_mainLabel];
//    
//    _detailLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, CGRectGetMaxY(_mainLabel.frame), 200, self.frame.size.height * 0.4)];
//    if (iPhone4) {
//        _detailLabel.frame = CGRectMake(10, CGRectGetMaxY(_mainLabel.frame), 100, self.frame.size.height * 0.4);
//    }
//    _detailLabel.text = @"";
//    _detailLabel.textAlignment = NSTextAlignmentLeft;
//    _detailLabel.textColor = [UIColor lightGrayColor];
//    _detailLabel.font = [UIFont systemFontOfSize:15];
//    [self.contentView addSubview:_detailLabel];
//    
//    _sysCodeLabel = [[UILabel alloc] init];
//    _sysCodeLabel.frame = CGRectMake(CGRectGetMaxX(_detailLabel.frame), _detailLabel.frame.origin.y, 100, _detailLabel.frame.size.height);
//    _sysCodeLabel.text = @"";
//    _sysCodeLabel.textAlignment = NSTextAlignmentLeft;
//    _sysCodeLabel.textColor = [UIColor lightGrayColor];
//    _sysCodeLabel.font = [UIFont systemFontOfSize:15];
//    [self.contentView addSubview:_sysCodeLabel];
//    
//    
//    
//    // 拖期按钮
//    _tuoBtn = [[UIButton alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_mainLabel.frame),_mainLabel.frame.origin.y, 60, _sysCodeLabel.frame.size.height)];
//    [_tuoBtn setTitle:@"" forState:UIControlStateNormal];
//    [_tuoBtn setTitleColor:RGBA(246, 113, 46, 1.0) forState:UIControlStateNormal];
//    _tuoBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
//    _tuoBtn.titleLabel.font = [UIFont systemFontOfSize:15];
//    [self.contentView addSubview:_tuoBtn];
//    
//    // 完成情况
//    _finLabel = [[UILabel alloc] initWithFrame:CGRectMake (CGRectGetMaxX(_tuoBtn.frame), _mainLabel.frame.origin.y, 60, _tuoBtn.frame.size.height)];
//    _finLabel.text = @"";
//    _finLabel.textAlignment = NSTextAlignmentLeft;
//    _finLabel.textColor = RGBA(32, 148, 32, 1.0);
//    _finLabel.font = [UIFont systemFontOfSize:15];
//    [self.contentView addSubview:_finLabel];
//    
//}

- (void)setModel:(MyOrderListModel *)model{

    _model = model;
    _mainLabel.text = model.REMARK;
    _detailLabel.text = model.TYPE_NAME;
    _sysCodeLabel.text = model.SYSCODE;
    [_tuoBtn setTitle:[NSString stringWithFormat:@"[%@]",model.STATE] forState:UIControlStateNormal];
    _finLabel.text = [NSString stringWithFormat:@"[%@]",model.ORDERSTATUS];
    
    if ([model.ORDERSTATUS isEqualToString:@"未完成"]) {
        _stateImageView.image = [UIImage imageNamed:@"red"];
    } else if ([model.STATE isEqualToString:@"拖期"]) {
        _stateImageView.image = [UIImage imageNamed:@"yellow"];
    } else {
        _stateImageView.image = [UIImage imageNamed:@"green"];
    }
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
